import java.util.Arrays;

public class MyStack1 {
    public int[]elem;
    public int usedSized;

    public MyStack1(){
        this.elem=new int[10];
    }
    public void push(int val){
        if(isFull()){
            elem=Arrays.copyOf(elem,elem.length);
        }
        elem[usedSized]=val;
        usedSized++;
    }
    public boolean isFull(){
        return usedSized==elem.length;
    }
    public int pop(){
        if(empty()){
            return -1;
        }
        int oldVal=elem[usedSized-1];
        usedSized--;
        return oldVal;
    }
    public int peek(){
        if (empty()) {
            return -1;
        }
        return elem[usedSized-1];
    }
    public boolean empty(){
        return usedSized==0;
    }
}
